package cn.iocoder.devlop.module.annual.report.enums;

import cn.iocoder.devlop.framework.common.core.ObjArrayValuable;
import cn.iocoder.devlop.module.annual.report.baseinfo.controller.vo.BaseinfoBaseVO;
import cn.iocoder.devlop.module.annual.report.entuser.controller.vo.EntuserBaseVO;
import cn.iocoder.devlop.module.annual.report.forinvestment.controller.vo.ForinvestmentBaseVO;
import cn.iocoder.devlop.module.annual.report.marpripinfo.controller.vo.MarpripinfoBaseVO;
import cn.iocoder.devlop.module.annual.report.subcapital.controller.vo.SubcapitalBaseVO;
import cn.iocoder.devlop.module.annual.report.websiteinfo.controller.vo.WebsiteinfoBaseVO;
import cn.iocoder.devlop.module.annual.report.wsbaseinfo.controller.vo.WsBaseinfoBaseVO;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public enum ChangeInfoNotificationEnum{
    ;

    @Getter
    @AllArgsConstructor
    public enum Type implements ObjArrayValuable {

        INSERT("INSERT", "新增"),
        UPDATE("UPDATE", "修改"),
        ;

        public static final String[] ARRAYS = Arrays.stream(values()).map(Type::getType).toArray(String[]::new);

        /**
         * 类型
         */
        private final String type;
        /**
         * 名字
         */
        private final String name;

        @Override
        public String[] array() {
            return ARRAYS;
        }

        public static Type getType(String type){
            return Arrays.stream(values()).filter(item->item.type.equals(type)).findFirst().orElse(null);
        }

    }

    @Getter
    @AllArgsConstructor
    public enum Target implements ObjArrayValuable {

        T_BASEINFO_2013("ECPS_BASEINFO_2013", BaseinfoBaseVO.class),
        T_BASEINFO_2023("ECPS_BASEINFO_2023", BaseinfoBaseVO.class),
        T_WS_BASEINFO_2013("CAPCS_WS_BASEINFO_2013", WsBaseinfoBaseVO.class),
        T_WS_BASEINFO_2023("CAPCS_WS_BASEINFO_2023", WsBaseinfoBaseVO.class),
        T_ENTUSER("ICIS_ENTUSER", EntuserBaseVO.class),
        T_MARPRIPINFO("ICIS_MARPRIPINFO", MarpripinfoBaseVO.class),
        T_SUBCAPITAL_2013("ECPS_SUBCAPITAL_2013", SubcapitalBaseVO.class),
        T_SUBCAPITAL_2023("ECPS_SUBCAPITAL_2023", SubcapitalBaseVO.class),
        T_FORINVESTMENT_2013("AN_FORINVESTMENT_2013", ForinvestmentBaseVO.class),
        T_FORINVESTMENT_2023("AN_FORINVESTMENT_2023", ForinvestmentBaseVO.class),
        T_WEBSITEINFO_2013("AN_WEBSITEINFO_2013", WebsiteinfoBaseVO.class),
        T_WEBSITEINFO_2023("AN_WEBSITEINFO_2023", WebsiteinfoBaseVO.class),
        ;

        public static final String[] ARRAYS = Arrays.stream(values()).map(Target::getTableName).toArray(String[]::new);

        /**
         * 类型
         */
        private final String tableName;
        /**
         * 名字
         */
        private final Class<?> cls;

        @Override
        public String[] array() {
            return ARRAYS;
        }

        public static Target getTarget(String tableName){
            return Arrays.stream(values()).filter(item->item.tableName.equals(tableName)).findFirst().orElse(null);
        }

        public static List<String> findTables(String tableName){
            return Arrays.stream(values()).filter(item->item.name().contains(tableName.toUpperCase())).map(e->e.name().toLowerCase()).collect(Collectors.toList());
        }

    }


}
